1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.geronimo;
|
18
|
|
|
19
|
|
import org.apache.commons.logging.Log;
|
20
|
|
import org.apache.commons.logging.LogFactory;
|
21
|
|
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
22
|
|
import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
|
23
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
24
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter;
|
25
|
|
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
26
|
|
|
27
|
|
import java.util.ArrayList;
|
28
|
|
import java.util.Iterator;
|
29
|
|
|
30
|
|
|
31
|
|
|
32
|
|
|
33
|
|
public class InternalBasedWrapperClassWriter extends JavaClassWriter {
|
34
|
|
protected static Log log =
|
35
|
|
LogFactory.getLog(InternalBasedWrapperClassWriter.class.getName());
|
36
|
|
protected final String seiName;
|
37
|
|
protected final String ejbName;
|
38
|
|
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|
|
44
|
0
|
public InternalBasedWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
|
45
|
|
throws GenerationFault {
|
46
|
0
|
super(j2eewscontext, getName(j2eewscontext) + "Impl");
|
47
|
0
|
seiName = j2eewscontext.getMiscInfo().getJaxrpcSEI();
|
48
|
0
|
ejbName = j2eewscontext.getEJBDDContext().getEjbName();
|
49
|
|
}
|
50
|
|
|
51
|
0
|
private static String getName(J2EEWebServiceContext j2eewscontext) {
|
52
|
0
|
String name =
|
53
|
|
j2eewscontext.getWSDLContext().gettargetBinding().getName();
|
54
|
0
|
if (name == null) {
|
55
|
0
|
name = j2eewscontext.getMiscInfo().getJaxrpcSEI();
|
56
|
|
}
|
57
|
0
|
return name;
|
58
|
|
}
|
59
|
|
|
60
|
0
|
protected String getimplementsPart() {
|
61
|
0
|
return " implements " + j2eewscontext.getMiscInfo().getJaxrpcSEI() + "," + "org.apache.geronimo.ews.ws4j2ee.wsutils.ContextAccessible";
|
62
|
|
}
|
63
|
|
|
64
|
0
|
protected void writeAttributes() throws GenerationFault {
|
65
|
0
|
out.write("private org.apache.axis.MessageContext msgcontext;\n");
|
66
|
0
|
out.write("\tprivate " + seiName + " bean = null;\n");
|
67
|
0
|
out.write("\tprivate org.openejb.EJBContainer container;\n");
|
68
|
|
}
|
69
|
|
|
70
|
0
|
protected void writeConstructors() throws GenerationFault {
|
71
|
0
|
out.write("\tpublic " + classname + "(){\n");
|
72
|
0
|
out.write("\t}\n");
|
73
|
|
}
|
74
|
|
|
75
|
0
|
protected void writeMethods() throws GenerationFault {
|
76
|
0
|
out.write("\tpublic void setMessageContext(org.apache.axis.MessageContext msgcontext){;\n");
|
77
|
0
|
out.write("\t\tthis.msgcontext = msgcontext;\n");
|
78
|
0
|
out.write("\t}\n");
|
79
|
0
|
String parmlistStr = null;
|
80
|
0
|
ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations();
|
81
|
0
|
for (int i = 0; i < operations.size(); i++) {
|
82
|
0
|
parmlistStr = "";
|
83
|
0
|
SEIOperation op = (SEIOperation) operations.get(i);
|
84
|
0
|
String returnType = op.getReturnType();
|
85
|
0
|
if (returnType == null)
|
86
|
0
|
returnType = "void";
|
87
|
0
|
out.write("\tpublic " + returnType + " " + op.getMethodName() + "(");
|
88
|
0
|
Iterator pas = op.getParameterNames().iterator();
|
89
|
0
|
boolean first = true;
|
90
|
0
|
while (pas.hasNext()) {
|
91
|
0
|
String name = (String) pas.next();
|
92
|
0
|
String type = op.getParameterType(name);
|
93
|
0
|
if (first) {
|
94
|
0
|
first = false;
|
95
|
0
|
out.write(type + " " + name);
|
96
|
0
|
parmlistStr = parmlistStr + name;
|
97
|
|
} else {
|
98
|
0
|
out.write("," + type + " " + name);
|
99
|
0
|
parmlistStr = parmlistStr + "," + name;
|
100
|
|
}
|
101
|
|
}
|
102
|
0
|
out.write(") throws java.rmi.RemoteException");
|
103
|
0
|
ArrayList faults = op.getFaults();
|
104
|
0
|
for (int j = 0; j < faults.size(); j++) {
|
105
|
0
|
out.write("," + (String) faults.get(i));
|
106
|
|
}
|
107
|
0
|
out.write("{\n");
|
108
|
0
|
out.write("\t\tString methodName = \"" + op.getMethodName() + "\";\n");
|
109
|
0
|
out.write("\t\tjava.lang.reflect.Method callMethod = Utils.getJavaMethod(\""
|
110
|
|
+ seiName
|
111
|
|
+ "\",methodName);\n");
|
112
|
0
|
out.write("\t\tClass[] classes = callMethod.getParameterTypes();\n");
|
113
|
0
|
out.write("\t\tObject[] arguments = new Object[]{");
|
114
|
0
|
pas = op.getParameterNames().iterator();
|
115
|
0
|
first = true;
|
116
|
0
|
while (pas.hasNext()) {
|
117
|
0
|
String name = (String) pas.next();
|
118
|
0
|
String type = op.getParameterType(name);
|
119
|
0
|
if (first) {
|
120
|
0
|
first = false;
|
121
|
0
|
out.write(Utils.getParameter(type, name));
|
122
|
|
} else {
|
123
|
0
|
out.write("," + Utils.getParameter(type, name));
|
124
|
|
}
|
125
|
|
}
|
126
|
0
|
out.write("};\n");
|
127
|
0
|
if (!"void".equals(returnType)) {
|
128
|
0
|
out.write("\t\t\treturn "
|
129
|
|
+ Utils.getReturnCode(returnType, "AxisGeronimoUtils.invokeEJB(\""
|
130
|
|
+ ejbName
|
131
|
|
+ "\",methodName,classes,arguments)")
|
132
|
|
+ ";\n");
|
133
|
|
} else {
|
134
|
0
|
out.write("\t\t\tAxisGeronimoUtils.invokeEJB(\""
|
135
|
|
+ ejbName
|
136
|
|
+ "\",methodName,classes,arguments);\n");
|
137
|
|
}
|
138
|
0
|
out.write("\t}\n");
|
139
|
|
}
|
140
|
|
}
|
141
|
|
|
142
|
|
|
143
|
|
|
144
|
|
|
145
|
0
|
protected void writeImportStatements() throws GenerationFault {
|
146
|
0
|
out.write("import org.apache.geronimo.axis.AxisGeronimoUtils;\n");
|
147
|
0
|
out.write("import org.apache.geronimo.ews.ws4j2ee.utils.Utils;\n");
|
148
|
|
}
|
149
|
|
|
150
|
|
}
|
151
|
|
|
152
|
|
|